<?php

class PENGUASALABSCHOOLModule extends CWebModule {

    public function init() {
        // this method is called when the module is being created
        // you may place code here to customize the module or the application
        // import the module-level models and components

        $this->setComponents(array(
            'errorHandler' => array(
                // use 'site/error' action to display errors
                'errorAction' => 'PENGUASALABSCHOOL/default/error',
            ),
            'user' => array(
                'class' => 'CWebUser',
            )
        ));

        $this->setImport(array(
            'PENGUASALABSCHOOL.models.*',
            'PENGUASALABSCHOOL.components.*',
            'application.components.*',
        ));
        $this->layoutPath = Yii::getPathOfAlias('PENGUASALABSCHOOL.views.layouts');
        $this->layout = 'admin';
        Yii::app()->errorHandler->errorAction = 'PENGUASALABSCHOOL/default/error';
        Yii::app()->user->setStateKeyPrefix("role");
        Yii::app()->user->loginUrl = Yii::app()->createUrl("PENGUASALABSCHOOL/login/index");
//        Yii::app()->errorHandler->errorAction="https://localhost".Yii::app()->createUrl("PENGUASALABSCHOOL/login/index");
    }

    public function beforeControllerAction($controller, $action) {
        if (parent::beforeControllerAction($controller, $action)) {
            // this method is called before any module controller action is performed
            // you may place customized code here
//            Yii::app()->errorHandler->errorAction = "PENGUASALABSCHOOL/login/index";
            $controller->layout = 'admin';
            return true;
        }
        else
            return false;
    }

}
